import { fileURLToPath, URL } from 'node:url'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
export default defineConfig({
  plugins: [
    vue(),
    AutoImport({
      resolvers: [ElementPlusResolver()]
    }),
    Components({
      resolvers: [ElementPlusResolver()]
    }),
  ],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    }
  },
  server: {
    port: 8080,
    proxy: {
      '/v2': {
        target: 'http://localhost:7001',
        changeOrigin: true
      }
    }
  },
 
  build: {
    minify: 'terser',
    terserOptions: {
      compress: {
         // 打包环境移除console.log，
        drop_console: true,
         // 打包环境移除debugger
        drop_debugger: true,
      },
      format: {
        comments: false
      }
    }
  }
})
